/**
 * 
 */

var noticeid = Ext.util.Cookies.get('noticeid');
Ext.util.Cookies.set('noticeid', null);
var role = Ext.util.Cookies.get('role');
Ext.util.Cookies.set('role', null);
var title, publisher, content, publishtime;

function init() {
	Ext.Ajax.request({
		url : 'noticeAction!queryNotice.action?id=' + noticeid,
		success : function(response) {
			var responseText = response.responseText;
			responseText = Ext.JSON.decode(responseText);
			var oneNotice = responseText.oneNotice;
			if (oneNotice != null) {
				title = oneNotice.title;
				publishername = oneNotice.publishername;
				content = oneNotice.content;
				var _publishtime = oneNotice.publishtime;
				if (_publishtime != null) {
					var dates = _publishtime.substr(0, 10).split("-");
					publishtime = new Date(dates[0], dates[1] - 1, dates[2],
							_publishtime.substr(11, 2), _publishtime.substr(14,
									2));
					publishtime = Ext.util.Format.date(publishtime,
							'Y年m月d日 H:i:s');
				} else {
					publishtime = "尚未发布";
				}
				Ext.getCmp('mypanel').body
						.update('<div align="center"><font size="5"><b>'
								+ title
								+ '</b></font><br><br><div align="right">'
								+ '时间：'
								+ publishtime
								+ '</font><br><br></div></div><div align="center">'
								+ '<div/><br><div align="center"><div align="left">'
								+ content + '</div></div>');
			}
		},
		failure : function(response) {
			alert("失败!");
		}
	});
}

Ext.onReady(function() {
			Ext.create('Ext.container.Viewport', {
						layout : 'fit',
						items : [{
							id : 'mypanel',
							autoScroll : true,
							bodyPadding : '10px 100px 10px 100px',
							xtype : 'panel',
							border : false,
							layout : 'fit',
							buttons : [{
								text : '关闭',
								id : 'closeBtn',
								handler : function() {
									if (role == 'quxian') {
										window.top.Utils.activePage("28");
										window.top.Utils.getTabWindow("28");

									} else {
										window.top.Utils.activePage("19");
										window.top.Utils.getTabWindow("19");
									}
									window.top.Utils.closePage('noticeQuery'
											+ noticeid);
								}
							}],
							buttonAlign : 'center'
						}]
					});
			init();
		});